<script setup name="Subcontracting">
import {
  GetListAPI,
  AddDataAPI,
  EditDataAPI,
  DelDataAPI,
  SubmitReviewAPI,
  GetDetailAPI,
  DeleteReviewAPI,
  ContractUploadAPI,
  ReviewSubmitAPI,
  GetContractListAPI,
  OrderUpdateAPI,
  ToExamineAPI,
  OrderDetailAPI,
  GenerateInvoiceAPI,
  SalesOrderAPI,
  getRawSaleDetailAPI,
  GetRawChecktAPI,
  getJinDieSaleAPI
} from '@/api/order/sale/order'
import Form from './form.vue'
import Create from './create.vue'
import verificatForm from './verificatForm.vue'
import beforeVerificatForm from './beforeVerificatForm.vue'
import Pull from './pull.vue'
const { proxy } = getCurrentInstance()

// 封装 方法 字典查询
const {
  sales_order_status, // 销售订单状态
  customer_affiliated_organization //所属机构
} = proxy.useDict('sales_order_status', 'customer_affiliated_organization')

const ruleForm = ref({})
const FormRef = ref(null)
const beforEverificatFef = ref(null)

const route = useRoute()
const BtnLoading = ref(false)

// 新增弹窗状态
const addIsShow = ref(false)

// 审核弹窗状态
const examineIsShow = ref(false)

//原料校验弹窗状态之前
const beforeVerificatIsShow = ref(false)

//原料校验弹窗状态
const verificatIsShow = ref(false)

// 上传解决方案弹窗状态
const upSolutionShow = ref(false)

// 方案审核弹窗状态
const SolutionShow = ref(false)

// 查看弹窗状态
const lookShow = ref(false)

/**
 * 拉取状态
 */
const pullShow = ref(false)

// 标题
const title = ref('新增')

// 发货单状态
const bomIdsDisabled = ref(false)
const bomIds = ref([])
// 保存加载状态
const Btnloading = ref(false)

// 表格加载状态
const loading = ref(false)

// 表格数据
const TableData = ref([])

// 列表总数量
const total = ref(0)

// 列表加载
const bomLoading = ref(false)

// 列表
const bomTableData = ref([])

// 列表选中数据
const bomSelection = ref([])

// 列表总数量
const bomTotal = ref(0)

// 列表查询
const bomQuery = reactive({
  pageNum: 1,
  pageSize: 10,
  id: '',
  salesOrderNum: route.query.value
})

// 手动关结
const closingShow = ref(false)

// 是否禁用删除
const DelDisabled = ref(false)

// 是否禁用 单选
const ExamineDisabled = ref(false)

//原料校验禁用
const verificatDisabled = ref(true)

//原料ref
const verificatFef = ref(null)

// 选中数据 id
const Ids = ref([])

const bomId = ref()
// 关结Id
const closingId = ref()
const bomRows = ref([])
// 选中数据
const rows = ref([])

// 查询条件
const query = reactive({
  pageNum: 1,
  pageSize: 10
  // salesOrderNum: route.query.value
})

const auditDocId = ref()

// 查询条件
const SelectList = ref([
  { type: '日期范围' },
  {
    label: '产品编码',
    model: 'materialCode',
    type: '输入框'
  },
  {
    label: '客户编码',
    model: 'customerNum',
    type: '输入框'
  },
  {
    label: '销售订单号',
    model: 'salesOrderNum',
    type: '输入框'
  },
  {
    label: '归属人',
    model: 'attributor',
    type: '输入框'
  },
  {
    label: '单据状态',
    model: 'status',
    type: '下拉单选',
    opt: sales_order_status
  },
  { label: '规格型号', model: 'specType', type: '输入框' }
])
// 列表枚举
const columnBom = ref([
  { label: '物料编码', prop: 'materialCode' },
  { label: '产品名称', prop: 'materialName', width: '180px' },
  { label: '单据状态', prop: 'orderDetailStatusDict', width: '140px' },
  { label: '规格型号', prop: 'specType' },
  { label: '交货日期', prop: 'deliveryDate' },
  { label: '订单数量(个)', prop: 'planWeight' },
  { label: '单价', prop: 'unitPrice' },
  { label: '已生产', prop: 'producedWeight' },
  { label: '未生产', prop: 'noProducedWeight' },
  { label: '出库量', prop: 'shippingWeight' },
  { label: '生产单号', prop: 'planNumber' },
  { label: '商品行备注', prop: 'remark' }
])

/**
 * 弹窗 SAT ------------------------
 */

//  新增单据 弹窗
const add = () => {
  title.value = '新增'
  addIsShow.value = true
}

/**
 * 新增
 */
const addDic = () => {}

//  修改单据 弹窗
const edit = async val => {
  if (val.status != 1) return proxy.successMsg('此操作仅为待提交状态可用')
  try {
    proxy.$modal.loading('请稍后')
    title.value = '修改'
    const res = await GetDetailAPI(val.id)
    ruleForm.value = res.data
    addIsShow.value = true
  } catch {
  } finally {
    proxy.$modal.closeLoading()
  }
}

// //  订单评审 弹窗
// const review = async () => {
//   title.value = '订单评审'
//   const res = await GetDetailAPI(Ids.value[0])
//   if (res.code !== 200) return
//   ruleForm.value = res.data
//   addIsShow.value = true
// }

//  合同上传 弹窗
const contractUp = async () => {
  const Obj = rows.value[0]
  if (Obj.status != 4) return proxy.warningMsg('此操作仅为待签订状态可用')
  title.value = '合同上传'
  const res = await GetDetailAPI(Ids.value[0])
  if (res.code !== 200) return
  ruleForm.value = res.data
  addIsShow.value = true
}

//  生成发货单 弹窗
const invoice = async () => {
  if (bomRows.value[0].orderDetailStatus != 9 && bomRows.value[0].orderDetailStatus != 6)
    return proxy.warningMsg('此操作仅为进行中或已终止状态可用')
  try {
    proxy.$modal.loading('请稍候...')
    title.value = '生成发货单'
    const res = await OrderDetailAPI(bomIds.value[0])
    if (res.code !== 200) return
    ruleForm.value = res.data
    ruleForm.value.salesOrderDetailList = res.data.salesOrderDetailDtoList
    addIsShow.value = true
  } catch {
  } finally {
    proxy.$modal.closeLoading()
  }
}

//  查看 弹窗
const dxamine = async val => {
  try {
    proxy.$modal.loading('请稍候...')

    title.value = '查看'
    Ids.value = [val.id]
    const res = await GetDetailAPI(val.id)
    ruleForm.value = res.data
    ruleForm.value.salesOrderDetailList = res.data.salesOrderDetailList
    addIsShow.value = true
  } catch {
  } finally {
    proxy.$modal.closeLoading()
  }
}

/**
 * 推送
 * @param val
 */
const pushData = async val => {
  try {
    const MesBox = await proxy.MessageBox(`"此操作会将销售合同号为${val.salesContractNum}推送至金蝶星辰
是否确定操作？"`)
    if (!MesBox) return
  } catch (error) {}
}

//  查看 单据明细修改
const boxDxamine = async val => {
  try {
    proxy.$modal.loading('请稍候...')

    title.value = '单据明细查看'
    rows.value = val
    const { data: res } = await OrderDetailAPI(val.id)
    auditDocId.value = `${res.salesOrderNum}${val.id}`
    ruleForm.value = res
    ruleForm.value.salesOrderDetailList = res.salesOrderDetailDtoList

    examineIsShow.value = true
  } catch {
  } finally {
    proxy.$modal.closeLoading()
  }
}

//  单据明细修改 弹窗
const bomEdit = async val => {
  if (val.orderDetailStatus == 1 || val.orderDetailStatus == 5 || val.orderDetailStatus == 7) {
    try {
      proxy.$modal.loading('请稍候...')
      title.value = '单据明细修改'
      const res = await OrderDetailAPI(val.id)
      if (res.code !== 200) return
      ruleForm.value = res.data
      ruleForm.value.salesOrderDetailList = res.data.salesOrderDetailDtoList
      addIsShow.value = true
    } catch {
    } finally {
      proxy.$modal.closeLoading()
    }
  } else {
    proxy.warningMsg('此操作仅为待提交或未通过或已退回状态可用')
  }
}

/**
 * 批量审核
 */
const allExamine = async () => {
  const is = rows.value.every(t => ['2', '3'].includes(t.status))
  if (!is) return proxy.warningMsg('只有待审核和审核中的数据可操作!')
  const num = rows.value.length
  const MesBox = await proxy.FreezMessageBox1(`共${num}条审核订单`)
  if (MesBox) {
    await ToExamineAPI({
      idStr: Ids.value.join(','),
      isAdopt: '1'
    })
    getList()
  } else {
    await ToExamineAPI({
      idStr: Ids.value.join(','),
      isAdopt: '2'
    })
    getList()
  }
}

// 下列表审核
const bomExamine = async val => {
  try {
    proxy.$modal.loading('请稍候...')
    rows.value = [val]
    bomId.value = val.salesOrderId
    if (val.orderDetailStatus != 2) return proxy.warningMsg('此操作仅为待审核状态可用')
    title.value = '订单评审'
    auditDocId.value = val.id
    const res = await OrderDetailAPI(val.id)
    ruleForm.value = res.data
    ruleForm.value.salesOrderDetailList = res.data.salesOrderDetailDtoList

    examineIsShow.value = true
  } catch {
  } finally {
    proxy.$modal.closeLoading()
  }
}

/**
 * 弹窗 END ------------------------
 */

// 新增
const addSub = async () => {
  try {
    const isif = await FormRef.value.submit()
    if (!isif) return
    Btnloading.value = true
    const res = await AddDataAPI(isif)
    if (res.code !== 200) return
    proxy.successMsg('新增成功')
    close()
    getList()
  } catch {
  } finally {
    Btnloading.value = false
  }
}

// 修改
const editSub = async () => {
  try {
    const isif = await FormRef.value.submit()
    if (!isif) return
    Btnloading.value = true
    const res = await EditDataAPI(isif)
    if (res.code !== 200) return
    proxy.successMsg('修改成功')
    close()
    getList()
  } catch {
  } finally {
    Btnloading.value = false
  }
}

const beforeverificaList = ref([])
const verificaList = ref([])
/**
 * 原料校验弹窗
 */
const verificat = async () => {
  try {
    const { data: res } = await getRawSaleDetailAPI(Ids.value[0])
    // const { data: res } = await GetRawChecktAPI(Ids.value[0])
    beforeverificaList.value = res
    title.value = '预览MRP运算'
    beforeVerificatIsShow.value = true
  } catch (err) {}
}

/**
 * 原料校验之前确认
 */
const beforEverificatSub = async () => {
  try {
    const MesBox = await proxy.MessageBox('确认直接去MRP运算吗？')
    if (!MesBox) return
    const res = await beforEverificatFef.value.submit()
    const arr = res.list.filter(item => item.computeNum != '' && item.computeNum != 0 && item.computeNum != '0')
    const result = await GetRawChecktAPI({ id: Ids.value[0], list: arr })
    verificaList.value = result.data
    title.value = 'MRP运算'
    verificatIsShow.value = true
  } catch (err) {
  } finally {
  }
}

/**
 * 拉取
 */
const pull = () => {
  pullShow.value = true
}

/**
 * 拉取确认
 */
const pullSub = async val => {
  proxy.$modal.loading('请稍候...')
  try {
    await getJinDieSaleAPI({
      pullDate: val.pullDate
    })
    pullShow.value = false
    proxy.successMsg('拉取成功')
    getList()
  } catch (error) {
  } finally {
    proxy.$modal.closeLoading()
  }
}

// 审核
const examine = async () => {
  const Obj = rows.value[0]
  if (Obj.status != 1) return proxy.warningMsg('此操作仅为待提交状态可用')
  const MesBox = await proxy.ExamineMessageBox()
  if (!MesBox) return
  const res = await SubmitReviewAPI(Obj.id)
  if (res.code !== 200) return
  proxy.successMsg('操作成功')
  getList()
}

// 订单评审提交
const subReview = async () => {
  const Obj = rows.value[0]
  if (Obj.status != 1) return proxy.warningMsg('此操作仅为待提交状态可用')
  const MesBox = await proxy.ExamineMessageBox()
  if (!MesBox) return
  await ReviewSubmitAPI(Ids.value[0])
  proxy.successMsg('操作成功')
  getList()
}

// 撤销审核
const revoke = async () => {
  const Obj = rows.value[0]
  if (Obj.status != 2) return proxy.warningMsg('此操作仅为待审核状态可用')
  const MesBox = await proxy.RevokeMessageBox()
  if (!MesBox) return
  const res = await DeleteReviewAPI(Ids.value[0])
  if (res.code !== 200) return (BtnLoading.value = false)
  proxy.successMsg('操作成功')
  getList()
}

// 合同上传提交
const upload = async () => {
  Btnloading.value = true
  try {
    const isif = await FormRef.value.submit()
    if (!isif) return
    const Obj = {
      contractUrl: isif.contractUrl,
      id: isif.id,
      salesContractNum: isif.salesContractNum
    }

    await ContractUploadAPI(Obj)
    proxy.successMsg('合同上传成功')
    close()
    getList()
  } catch {
  } finally {
    Btnloading.value = false
  }
}

// 手动关结
const closingSub = async val => {
  await SalesOrderAPI(val)
  closingShow.value = false
  proxy.successMsg('关结成功')
  getList()
}

// 明细修改
const orderUpdate = async () => {
  try {
    const isif = await FormRef.value.submit()
    if (!isif) return
    Btnloading.value = true
    const res = await OrderUpdateAPI(isif.salesOrderDetailDtoList[0])
    if (res.code !== 200) return
    proxy.successMsg('修改成功')
    close()
    getList()
  } catch {
  } finally {
    Btnloading.value = false
  }
}

// 审核同意 || 不同意  (同意1 不同意 2)
const yesAndNo = async val => {
  const isif = await FormRef.value.submit()
  if (!isif) return
  try {
    BtnLoading.value = true
    const form = {
      reviewComments: isif.reviewComments,
      idStr: auditDocId.value,
      isAdopt: val
    }
    await ToExamineAPI(form)
    examineIsShow.value = false
    getList()
    proxy.successMsg('操作成功')
  } catch {
  } finally {
    BtnLoading.value = false
  }
}

// 生成
const generate = async () => {
  const isif = await FormRef.value.submit()
  if (!isif) return
  try {
    BtnLoading.value = true
    const aif = isif.salesOrderDetailDtoList.every(item => item.plannedWeight)
    if (!aif) return proxy.warningMsg('请填写计划数量')
    isif.list = isif.salesOrderDetailDtoList
    const list = isif.list.map(item => ({
      id: item.id,
      connectionId: isif.salesOrderNum,
      materialCode: item.materialCode,
      materialId: item.materialId,
      plannedWeight: item.plannedWeight
    }))
    await GenerateInvoiceAPI({
      customId: isif.customerId,
      id: isif.id,
      list
    })
    getList()

    addIsShow.value = false
    proxy.successMsg('操作成功')
  } catch {
  } finally {
    BtnLoading.value = false
  }
}

// 删除
const del = async val => {
  const MesBox = await proxy.DelMessageBox()
  if (!MesBox) return
  await DelDataAPI(Ids.value.length <= 0 ? val : Ids.value.join(','))
  getList()
  proxy.successMsg('删除成功')
}

// 列表选中 及 判断是否禁用删除 || 修改 verificatDisabled
const handleSelectionChange = selection => {
  rows.value = selection
  Ids.value = selection.map(item => item.id)
  DelDisabled.value = !selection.length
  selection.length <= 0 || selection.length > 1 ? (ExamineDisabled.value = true) : (ExamineDisabled.value = false)
  selection.length == 1 ? (verificatDisabled.value = false) : (verificatDisabled.value = true)
}
handleSelectionChange([])

// 点击列表
const clickhandleSelection = val => {
  // Ids.value = [val.id]
  getBomList(val.id)
}

// 下列表
const bomHandleSelectionChange = selection => {
  // console.log(selection)
  bomRows.value = selection
  bomIds.value = selection.map(item => item.id)
  bomIdsDisabled.value = !bomIds.value.length
}
bomHandleSelectionChange([])

// 弹窗关闭
const close = () => {
  addIsShow.value = false
  BtnLoading.value = false
  examineIsShow.value = false
  verificatIsShow.value = false
  beforeVerificatIsShow.value = false
  ruleForm.value = {}
}

// 条件查询
const selectSubmit = Obj => {
  // query.salesOrderNum = ''
  for (let KEY in Obj) {
    query[KEY] = Obj[KEY]
  }
  // console.log(query)
  getList()
}

// 获取列表
const getList = async () => {
  loading.value = true
  try {
    const res = await GetListAPI(query)
    total.value = res.total
    TableData.value = res.rows
    loading.value = false
    bomQuery.id = res.rows[0].id
    getBomList(res.rows[0].id)
  } catch (error) {
    loading.value = false
  } finally {
    loading.value = false
  }
}

// XSDD-20241102-00003
// 获取下列表
const getBomList = async id => {
  bomQuery.id = id
  bomLoading.value = true
  try {
    const res = await GetContractListAPI(bomQuery)
    if (res.code !== 200) return
    bomTotal.value = res.total
    bomTableData.value = res.rows
    bomLoading.value = false
  } catch (error) {
    bomLoading.value = false
  } finally {
    bomLoading.value = false
  }
}

getList()

const tableHeight = ref(0)

const maxHeight = computed(() => {
  const windowHeight = window.innerHeight
  const headerHeight = 650
  const paginationHeight = 0
  return windowHeight - headerHeight - paginationHeight
})

const handleResize = () => {
  tableHeight.value = maxHeight.value
}

onMounted(() => {
  tableHeight.value = maxHeight.value
  window.addEventListener('resize', handleResize)
})

onBeforeUnmount(() => {
  window.removeEventListener('resize', handleResize)
})
</script>

<template>
  <div class="app-container">
    <!-- 查询条件组件 -->
    <SelectForm :SelectForm="SelectList" @selectSubmit="selectSubmit" />
    <el-card class="box-card">
      <el-button type="primary" v-hasPermi="['order:sale:saleOrder:add']" @click="add">添加单据</el-button>

      <el-button
        type="danger"
        v-hasPermi="['order:sale:saleOrder:subExamine']"
        :disabled="ExamineDisabled"
        @click="subReview"
        >提交审核
      </el-button>
      <el-button
        type="warning"
        v-hasPermi="['order:sale:saleOrder:orderReview']"
        :disabled="DelDisabled"
        @click="allExamine"
        >批量审核</el-button
      >
      <el-button type="primary" v-hasPermi="['order:sale:saleOrder:revoke']" :disabled="ExamineDisabled" @click="revoke"
        >撤销审核</el-button
      >
      <el-button
        type="success"
        v-hasPermi="['order:sale:saleOrder:contractUp']"
        :disabled="ExamineDisabled"
        @click="contractUp"
        >合同上传</el-button
      >
      <el-button
        type="success"
        v-hasPermi="['order:sale:saleOrder:invoice']"
        :disabled="bomIdsDisabled"
        @click="invoice"
        >生成发货单</el-button
      >
      <el-button
        type="success"
        v-hasPermi="['order:sale:saleOrder:manualClosing']"
        :disabled="ExamineDisabled"
        @click="closingShow = true"
        >手动关结</el-button
      >
      <el-button type="danger" v-hasPermi="['order:sale:saleOrder:remove']" :disabled="DelDisabled" @click="del"
        >删除</el-button
      >
      <el-button type="info" v-hasPermi="['order:sale:saleOrder:import']" @click="importFn">导入</el-button>
      <el-button type="info" v-hasPermi="['order:sale:saleOrder:export']" @click="exportFn">导出</el-button>
      <el-button
        type="success"
        v-hasPermi="['order:sale:saleOrder:verificat']"
        :disabled="verificatDisabled"
        @click="verificat"
        >原料校验</el-button
      >
      <el-button type="success" v-hasPermi="['order:sale:saleOrder:pull']" @click="pull">拉取</el-button>
      <!-- 表格数据 -->
      <div class="table tableClass">
        <div class="top">
          <!-- 上列表 -->
          <el-table
            v-loading="loading"
            stripe
            border
            fit
            height="300px"
            :data="TableData"
            @selection-change="handleSelectionChange"
            @row-click="clickhandleSelection"
          >
            <el-table-column type="selection" width="55" align="center" fixed="left" />
            <el-table-column label="序号" width="70" type="index" />
            <el-table-column label="销售订单号" prop="salesOrderNum" width="220" />
            <el-table-column label="销售合同号" prop="salesContractNum" width="220">
              <template #default="scope">
                {{ scope.row.salesContractNum }}
              </template>
            </el-table-column>
            <el-table-column label="客户编码" prop="customerNum" width="120" />
            <el-table-column label="客户名称" prop="customerName" width="220" />
            <el-table-column label="单据状态" align="center" width="120">
              <template #default="scope">
                <div>
                  <p-tag bgc="#006cb6" text="待提交" v-if="scope.row.status == 1" />
                  <p-tag bgc="#fbc82f" text="待审核" v-else-if="scope.row.status == 2" />
                  <p-tag bgc="#f28e16" text="审核中" v-else-if="scope.row.status == 3" />
                  <p-tag bgc="#8e7cc3" text="待签订" v-else-if="scope.row.status == 4" />
                  <p-tag bgc="#593fd7" text="进行中" v-else-if="scope.row.status == 5" />
                  <p-tag bgc="#bebebe" text="已完成" v-else-if="scope.row.status == 6" />
                  <p-tag bgc="#9a9a9a" text="已关结" v-else />
                </div>
              </template>
            </el-table-column>

            <el-table-column label="订单类型" prop="orderTypeDict" width="150" />
            <el-table-column label="订单优先级" prop="orderPriorityDict" width="150" />
            <el-table-column label="归属人" prop="attributor" width="100" />
            <el-table-column label="开单人" prop="createBy" width="100" />
            <el-table-column label="开单时间" prop="createTime" width="200" />
            <el-table-column label="审核人" prop="reviewBy" width="100" show-overflow-tooltip />
            <el-table-column label="审核时间" prop="reviewTime" width="100" show-overflow-tooltip />

            <el-table-column
              label="操作"
              align="center"
              width="200"
              fixed="right"
              class-name="small-padding fixed-width"
            >
              <template #default="scope">
                <div>
                  <el-link v-show="scope.row.status == 1" type="primary" text="修改" @click="edit(scope.row)" />
                  <el-link v-show="scope.row.status == 1" type="primary" text="删除" @click="del(scope.row.id)" />
                  <el-link type="primary" text="查看" @click="dxamine(scope.row)" />
                  <!-- <el-link type="primary" text="推送" @click="pushData(scope.row)" /> -->
                </div>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <pagination
          :fixed="false"
          v-show="total > 0"
          :total="total"
          v-model:page="query.pageNum"
          v-model:limit="query.pageSize"
          @pagination="getList"
        />
        <div class="buttom">
          <!-- 下列表 -->
          <div class="title">单据明细</div>
          <p-table
            keyId="id"
            :height="maxHeight"
            :column="columnBom"
            :total="bomTotal"
            v-model:page="bomQuery.pageNum"
            v-model:limit="bomQuery.pageSize"
            @pagination="getBomList(bomQuery.id)"
            stripe
            border
            :loading="bomLoading"
            :data="bomTableData"
            highlight-current-row
            @change="bomHandleSelectionChange"
          >
            <template #columnCell="{ column, record }"> </template>
          </p-table>
        </div>
      </div>
    </el-card>
    <!-- 新增弹窗 -->
    <p-XiaoheDialog :dialogVisible="addIsShow" :title="title" @close="close" width="80%">
      <template #body>
        <Form
          :data="ruleForm"
          ref="FormRef"
          :isIfKey="title"
          v-if="title == '修改' || title == '查看' || title == '新增'"
        />
        <Create :data="ruleForm" ref="FormRef" :isIfKey="title" v-else-if="title == '生成发货单'" />
        <Form :data="ruleForm" ref="FormRef" :isIfKey="title" v-else />

        <!-- 按钮 新增或者修改-->
        <div class="flex-between btn" v-if="title == '修改' || title == '新增'">
          <div></div>
          <div>
            <el-button :loading="BtnLoading" type="primary" @click="title == '新增' ? addSub() : editSub()"
              >保存</el-button
            >
            <el-button @click="close">取消</el-button>
          </div>
        </div>

        <!-- 按钮 合同上传-->
        <div class="flex" v-if="title == '合同上传'">
          <div style="flex: 1"></div>
          <div class="Btn">
            <el-button type="danger" :loading="BtnLoading" @click="upload">上传</el-button>
            <el-button type="inof" @click="close">取消</el-button>
          </div>
        </div>
        <!-- 按钮 生成发货单-->
        <div class="flex" v-if="title == '生成发货单'">
          <div style="flex: 1"></div>
          <div class="Btn">
            <el-button type="danger" :loading="BtnLoading" @click="generate">生成</el-button>
            <el-button type="inof" @click="close">取消</el-button>
          </div>
        </div>
        <!-- 按钮 单据明细修改-->
        <div class="flex" v-if="title == '单据明细修改'">
          <div style="flex: 1"></div>
          <div class="Btn">
            <el-button type="primary" :loading="BtnLoading" @click="orderUpdate">保存</el-button>
            <el-button type="inof" @click="close">取消</el-button>
          </div>
        </div>
      </template>
    </p-XiaoheDialog>
    <!-- 审核弹窗 -->
    <p-XiaoheDialog :dialogVisible="examineIsShow" :title="title" @close="close" width="70%">
      <template #body>
        <AuditHistory :auditDoc="auditDocId" perms="order:sale:saleOrder:examine">
          <template #body>
            <Form :data="ruleForm" ref="FormRef" :isIfKey="title" />
            <div class="Btn" v-if="title == '订单评审'">
              <el-button type="danger" :loading="Btnloading" @click="yesAndNo(2)">不同意</el-button>
              <el-button type="success" :loading="Btnloading" @click="yesAndNo(1)">同意</el-button>
              <el-button type="inof" @click="close">取消</el-button>
            </div>
          </template>
        </AuditHistory>
      </template>
    </p-XiaoheDialog>

    <!-- 原料校验之前 -->
    <p-XiaoheDialog :dialogVisible="beforeVerificatIsShow" :title="title" @close="close" width="60%">
      <template #body>
        <beforeVerificatForm ref="beforEverificatFef" :data="beforeverificaList" :id="Ids[0]" />
        <div class="flex">
          <div style="flex: 1"></div>
          <div class="Btn">
            <el-button type="primary" @click="beforEverificatSub">开始运算</el-button>
            <el-button type="inof" @click="close">取消</el-button>
          </div>
        </div>
      </template>
    </p-XiaoheDialog>

    <!-- 原料校验 -->
    <p-XiaoheDialog :dialogVisible="verificatIsShow" :title="title" @close="close" width="70%">
      <template #body>
        <verificatForm ref="verificatFef" :data="verificaList" @ok="verificatIsShow = false" :id="Ids[0]" />
      </template>
    </p-XiaoheDialog>

    <!-- 手动关结 -->
    <closing v-if="closingShow" :id="Ids[0]" :isShow="closingShow" @submit="closingSub" @close="closingShow = false" />

    <!-- 拉取组件 -->
    <Pull v-if="pullShow" :is-show="pullShow" @preservation="pullSub" @cancel="pullShow = false" />
  </div>
</template>

<style lang="scss" scoped>
.table {
  // height: 40rem;
  // .top {
  //   height: 50%;
  // }
  // .buttom {
  //   height: 30%;
  //   overflow: auto;
  // }
}
</style>
